package com.tengol.demo.design.pattern.structural.adapter.demo;

/**
 * PowerAdapter
 *
 * @author dongrui
 * @date 2019/03/07
 */
public class PowerAdapter implements IDC5{
    private AC220 ac220;

    public PowerAdapter(AC220 ac220){
        this.ac220 = ac220;
    }

    public int outputDc5() {
        int outputAc220 = ac220.outputAC220();
        System.out.println("手机充电器：输入交流电" + outputAc220 + "V");
        //变压器，将220V交流电转换为5V的直流电
        int dc5 = ac220ToDc5(outputAc220);
        System.out.println("手机充电器：输出直流电" + dc5 + "V");
        return dc5;
    }

    private int ac220ToDc5(int ac220){
        return ac220 / 44;
    }
}
